﻿using System;

namespace FallingRox
{
    class FallingRoxMain
    { 
        public const int WorldRows = 40;
        public const int WorldCols = 85;

        static void Main()
        {
            Console.WindowHeight = FallingRoxMain.WorldRows + 4;
            Console.WindowWidth = FallingRoxMain.WorldCols + 1;

            IRenderer renderer = new ConsoleRenderer(WorldRows, WorldCols);
            IUserInput keyboard = new KeyboardInput();
            Collider collider = new Collider();
            Rocket rocket = new Rocket(new MatrixCoords(35, 30));
            Engine gameEngine = new Engine(renderer, collider, rocket, keyboard, (int)GameDifficulty.Medium);

            // implementation of keyboard events
            keyboard.OnLeftArrowPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveRocketLeft();
            };

            keyboard.OnRightArrowPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveRocketRight();
            };

            keyboard.OnUpArrowPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveRocketUp();
            };

            keyboard.OnDownArrowPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveRocketDown();
            };

            keyboard.OnSpaceBarPressed += (sender, eventInfo) =>
            {
                gameEngine.ShootBullet();
            };

            gameEngine.Run();
        }
    }
}
